All installation tips below are fragments of this blog post. Please visit it for more detailed information.
R is a statistical programming language and a software itself. We will use it as the base software for our analyses.
To install R go to https://cloud.r-project.org, follow the links for your platform, download and install the current R binaries for base distribution. Do not create any menu items or task bar entries. You will not need them as you will be using R via RStudio.
While not strictly required, Rtools help to make projects reproducible cross-platform – we might skip it for now.
Again, installing Rtools essentially means going to https://cran.r-project.org/bin/windows/Rtools/ and downloading the according file.
After installation, make sure that you add it to your PATH
environment variable. In RStudio, copy-and-paste the command below in
the R console (the thing on the left side of RStudio), and press
Enter:
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")RStudio is an Integrated Development Environment (IDE) centered on R, which offers everything you need to bridge to other programming languages and tools. We will rely on RStudio to run R, write reports using R Markdown and collaborate using its integration to Git.
To install RStudio go to https://rstudio.com/products/rstudio/download/, download and install the free Desktop version. You can add a task bar entry, as you will need it.
Git will help us to keep track of versions of our work and to collaborate with others on a project and you work on it concurrently.
First, we will create your GitHub account at https://github.com/join. You will need to give an username, email and confirm it. GitHub will send a first email to confirm that it is you.
Prior to using Git with RStudio, you should install it using the appropriate method for your platform:
sudo apt-get install git-coresudo yum install git-coreClick on Next buttons until the Install
button appears and click on it.
After installing Git you need to configure it. To set your user name
and password using RStudio, go to Terminal tab (Fig.
1):
Fig. 1. Terminal tab
In the Terminal tab, run the following code (change to
your name and email):
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"In RStudio, go to Tools >
Global Options... > Git/SVN
The window below will prompt (Fig. 2).
Fig. 2. Global Options
Then:
Enable version control for RStudio projectsCreate SSH Key... and click on
CreateView public key, and press Crtl +
C to copy the key to the clipboardYou will need to add a key to link your GitHub to RStudio.
Go to https://github.com/settings/keys:
New SHH keyCrtl + V) the key from your
clipboardAdd SSH keyWe are going to create a repository, link it to an RStudio project, update the project with an R Markdown file, and upload this file to the repository.
Now, go to http://github.com/new:
r_sandboxPrivateAdd a README fileAdd .gitignore (and pick R as your
.gitignore template)Create RepositoryCode > SSH and copy
(Crtl + C) the repository URL to your
clipboardIn RStudio, go to File > New Project...
> Version Control > Git
Crtl + V) the URL for
r_sandbox repository from your clipboardgit to save all your repositories in one
single place)Create Projectyes and click on OKFig. 3. First time Github authentication
You might need to close RStudio or even restart your computer if that does not work the first time around. Then, follow the steps above again.
In RStudio, go to File > New file >
R Markdown...
If RStudio asks to install some packages (Fig. 4), please allow it to
do so by clicking on Yes (Sim in
Portuguese)
Fig. 4. Git tab
OK
buttonFile > Knit Document or simply
click on Knit button, and you will have your first
reportIn RStudio, go to Tools >
Version Control > Commit. Alternativaly,
you can go to Git tab > Commit
Fig. 5. Git tab
In the pop-up window (Fig. 5):
Crtl + A to select all files and
click on Stage (or you can also click on each file so that
they are all ticked)Commit message, e.g. “My first
commit”Commit, and click on Close once
it’s donePush, and click on Close once
it’s doneGo to your GitHub page on https://github.com/ and see your r_sandbox
repository updated.